package com.wm.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wm.common.utils.StringUtils;
import com.wm.system.domain.ShopInfo;
import com.wm.system.mapper.ShopInfoMapper;
import com.wm.system.service.IShopInfoService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author hyq
 * @since 2023-10-09 12:01:56
 */
@Service
public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> implements IShopInfoService {

    @Override
    public List<ShopInfo> selectShopInfoList(ShopInfo shopInfo) {
        List<ShopInfo> list = this.lambdaQuery().like(StringUtils.isNotEmpty(shopInfo.getShopName()), ShopInfo::getShopName, shopInfo.getShopName())
                .list();
        return list;
    }

    @Override
    public void addOrUpdate(ShopInfo shopInfo) {
        if(shopInfo.getId()==null){
            shopInfo.setState("1");
            shopInfo.setCreateTime(LocalDateTime.now());
        }
        this.saveOrUpdate(shopInfo);
    }

    @Override
    public ShopInfo getInfo(ShopInfo shopInfo) {
        ShopInfo byId = this.getById(shopInfo.getId());
        return byId;
    }
}
